# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_python//python:defs.bzl", "py_library")
load("//bazel:serving.bzl", "serving_cc_binary", "serving_cc_library")

package(default_visibility = ["//visibility:public"])

proto_library(
    name = "inference_service_proto",
    srcs = ["inference_service.proto"],
    deps = [
        "//secretflow_serving/apis:status_proto",
    ],
)

cc_proto_library(
    name = "inference_service_cc_proto",
    deps = [":inference_service_proto"],
)

proto_library(
    name = "config_proto",
    srcs = ["config.proto"],
)

cc_proto_library(
    name = "config_cc_proto",
    deps = [":config_proto"],
)

serving_cc_library(
    name = "control_service_impl",
    srcs = ["control_service_impl.cc"],
    hdrs = ["control_service_impl.h"],
    deps = [
        ":inference_service_cc_proto",
        "//secretflow_serving/apis:error_code_cc_proto",
        "@brpc",
    ],
)

serving_cc_library(
    name = "inference_executor",
    srcs = ["inference_executor.cc"],
    hdrs = ["inference_executor.h"],
    deps = [
        ":config_cc_proto",
        ":control_service_impl",
        "//secretflow_serving/server",
    ],
)

serving_cc_binary(
    name = "inferencer",
    srcs = ["main.cc"],
    deps = [
        ":inference_executor",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/core:logging",
        "@abseil-cpp//absl/debugging:failure_signal_handler",
        "@abseil-cpp//absl/debugging:symbolize",
    ],
)

py_library(
    name = "inferencer_wrapper",
    data = [
        ":inferencer",
    ],
)
